<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.0.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/hexo/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/hexo/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/hexo/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/hexo/images/logo.svg" color="#222">

<link rel="stylesheet" href="/hexo/css/main.css">


<link rel="stylesheet" href="/hexo/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"hf98.gitee.io","root":"/hexo/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="VLAN1. 基础概念1. VLAN(virtual local area network)用于二层分割广播域，提高交换机的灵活性，简化配置，同时有效增强局域网的泛洪。     1 VLAN&#x3D; 1广播域 &#x3D; 1子网 不同VLAN下的设备默认无法通讯，需采用三层设备互通。 2.PVID：端口vlanId,用于交换机转发包识别 2. 数据包形式VLAN正式标准：802.1q，对Ethernet帧格式进">
<meta property="og:type" content="article">
<meta property="og:title" content="VLAN">
<meta property="og:url" content="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/">
<meta property="og:site_name" content="梁汉烽的博客">
<meta property="og:description" content="VLAN1. 基础概念1. VLAN(virtual local area network)用于二层分割广播域，提高交换机的灵活性，简化配置，同时有效增强局域网的泛洪。     1 VLAN&#x3D; 1广播域 &#x3D; 1子网 不同VLAN下的设备默认无法通讯，需采用三层设备互通。 2.PVID：端口vlanId,用于交换机转发包识别 2. 数据包形式VLAN正式标准：802.1q，对Ethernet帧格式进">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/VLAN_md_files/image_20200713112036.png?v=1&type=image&token=V1:OioDaU9c6quhcoipWkP3nk-9rNpjaZjsJzN6CM3Hsww">
<meta property="og:image" content="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/VLAN_md_files/image_20200713142548.png?v=1&type=image&token=V1:UygzmYjJdlKv5QniMpAljxxBwqhG087Q0DM9Q434uTg">
<meta property="og:image" content="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/VLAN_md_files/image_20200713144640.png?v=1&type=image&token=V1:tSMl8l_xiPrhsGrJnyDD-J4U1bWFg1VhFLY95jGF9YQ">
<meta property="og:image" content="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/VLAN_md_files/image_20200713163815.png?v=1&type=image&token=V1:y_RTTn_P5nc-e8uOU6dzd9PRiawMt-O4BgGNpiaDLI8">
<meta property="article:published_time" content="2020-07-04T16:00:00.000Z">
<meta property="article:modified_time" content="2020-08-10T06:38:38.466Z">
<meta property="article:author" content="Liang HF">
<meta property="article:tag" content="网络">
<meta property="article:tag" content="VLAN">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/VLAN_md_files/image_20200713112036.png?v=1&type=image&token=V1:OioDaU9c6quhcoipWkP3nk-9rNpjaZjsJzN6CM3Hsww">

<link rel="canonical" href="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>VLAN | 梁汉烽的博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/hexo/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">梁汉烽的博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">日常学习总结</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/hexo/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/hexo/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/hexo/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/hexo/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://hf98.gitee.io/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/VLAN/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/hexo/images/avatar.gif">
      <meta itemprop="name" content="Liang HF">
      <meta itemprop="description" content="普通人">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="梁汉烽的博客">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          VLAN
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-07-05 00:00:00" itemprop="dateCreated datePublished" datetime="2020-07-05T00:00:00+08:00">2020-07-05</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-08-10 14:38:38" itemprop="dateModified" datetime="2020-08-10T14:38:38+08:00">2020-08-10</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/hexo/categories/%E8%B7%AF%E7%94%B1%E4%BA%A4%E6%8D%A2/" itemprop="url" rel="index"><span itemprop="name">路由交换</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="VLAN"><a href="#VLAN" class="headerlink" title="VLAN"></a>VLAN</h2><h3 id="1-基础概念"><a href="#1-基础概念" class="headerlink" title="1. 基础概念"></a>1. 基础概念</h3><pre><code>1. VLAN(virtual local area network)用于二层分割广播域，提高交换机的灵活性，简化配置，同时有效增强局域网的泛洪。
    1 VLAN= 1广播域 = 1子网
不同VLAN下的设备默认无法通讯，需采用三层设备互通。
2.PVID：端口vlanId,用于交换机转发包识别</code></pre>
<h3 id="2-数据包形式"><a href="#2-数据包形式" class="headerlink" title="2. 数据包形式"></a>2. 数据包形式</h3><p>VLAN正式标准：802.1q，对Ethernet帧格式进行了修改，<strong>添加了4字节的Tag字段</strong>，其中有12bit长的VLAN ID字节位</p>
<h3 id="3-链路接入类型"><a href="#3-链路接入类型" class="headerlink" title="3.链路接入类型"></a>3.链路接入类型</h3><p>1.access（接入链路）：用于连接<strong>主机和交换机</strong>的链路，其中帧均为untagged帧</p>
<pre><code>接入规则：
    1.接收到数据包会根据端口添加PVID
    2.然后根据Tag中的VLANId找寻相同VLAN的端口转发
    2.转发前移除VLAN tag</code></pre>
<ol start="2">
<li><p>trunk（干道/中继链路）：用于<strong>交换机之间的互连或 交换机与路由器之间</strong>的链路，帧大部分位tagged帧</p>
<pre><code> 接入规则：
     接收：
         1.如果帧不包含tag,将打上端口PVID
         2.如果该帧包含tag,则不改变
     发送：
         1.若与端口的PVID相同，则剥离tag发送
         2.若与端口的PVID不同，则直接发送</code></pre>
</li>
<li><p>hybrid（混杂模式）<br> 灵活的接入方式</p>
<pre><code> 接入规则：
     1.允许多个VLAN的帧通过
     2.并且可以在接口将VLAN帧的Tag剥离</code></pre>
<h3 id="3-VLAN规划"><a href="#3-VLAN规划" class="headerlink" title="3.VLAN规划"></a>3.VLAN规划</h3></li>
<li><p>基于端口：根据端口划分VLAN方式</p>
</li>
<li><p>基于MAC端口划分VLAN（即根据NIC的mac地址划分，统计量偏大）</p>
<pre><code> 不同VLAN间通讯：每个VLAN一个物理链接，路由链路剥离vlan接口
 缺点：会导致过多物理链路，限制于路由接口多少
 解决方法：
 1.采用trunk链路实现单臂路由
     1.路由器创建子接口 接口后带小数点（可创建数量与VLAN可创建数量相同）
     2.路由器子接口关联VLAN号
     3.设置ip地址
     4.开启arp广播 
 2.采用三层交换（不需要路由）
     1.创建虚拟网络接口（需对应vlan号）
     2.配置IP地址</code></pre>
</li>
</ol>
<h3 id="4-VLAN配置命令总结"><a href="#4-VLAN配置命令总结" class="headerlink" title="4.VLAN配置命令总结"></a>4.VLAN配置命令总结</h3><pre><code>系统模式：
    vlan [vlanId| batch created]             创建VLAN
            1    |    10 to 20
    （路由）int [interface].[vlanId]            创建虚拟路由子接口
    int vlanif [vlanId]                        三层交换创建vlan虚拟接口
    display port vlan 查看端口VLAN情况
接口模式：
    port link-type access/trunk/hybird         配置接口类型
    port default vlan [vlanId]                配置access端口vlanId
    port trunk allow-pass vlan [vlanId]        配置trunk模式下允许通过的vlan包
    port [trunk|hybird] pvid vlan [vlanId]     配置不同模式的vlanId
    port hybird tagged/untagged vlan [vlanId] 配置hybird标记规则
    （路由）dotlq terminiation vid [vlanId]     开启虚拟接口承载VLAN
    （路由）arp broadcast enable                虚拟接口开启ARP广播</code></pre>
<h3 id="5-基础实验总结"><a href="#5-基础实验总结" class="headerlink" title="5.基础实验总结"></a>5.基础实验总结</h3><ol>
<li><p>VLAN内相通（实际物理链路）</p>
<p> 1.交换机采用vlan不同链路接入方式均需要先创建VLAN，否则放通无效，SW收到包会丢弃<br> 2.终端设备链路尽可能去除vlan标签（采用hybird相对灵活）<br> 3.汇聚链路采用trunk并根据需求放通相关VLAN<br><img src="VLAN_md_files/image_20200713112036.png?v=1&type=image&token=V1:OioDaU9c6quhcoipWkP3nk-9rNpjaZjsJzN6CM3Hsww">    </p>
</li>
<li><p>单臂路由<br><img src="VLAN_md_files/image_20200713142548.png?v=1&type=image&token=V1:UygzmYjJdlKv5QniMpAljxxBwqhG087Q0DM9Q434uTg"></p>
</li>
<li><p>三层交换（虚拟网络接口）</p>
<pre><code> 1.创建虚拟接口
 2.配置接口IP地址</code></pre>
<p><img src="VLAN_md_files/image_20200713144640.png?v=1&type=image&token=V1:tSMl8l_xiPrhsGrJnyDD-J4U1bWFg1VhFLY95jGF9YQ"></p>
<h3 id="6-VLAN综合实验"><a href="#6-VLAN综合实验" class="headerlink" title="6. VLAN综合实验"></a>6. VLAN综合实验</h3><p> 要点：</p>
<pre><code> 1.    汇聚层交换机通过三层虚拟接口实现网段分割，变成网络边界
 2.    上层交换机之间采用vlan+三层虚拟接口互访，vlan类型为access（剥离VLAN标签即可，非必须）
 3.    下层PC通过汇聚层交换机虚拟接口实现VLAN间互访</code></pre>
<p><img src="VLAN_md_files/image_20200713163815.png?v=1&type=image&token=V1:y_RTTn_P5nc-e8uOU6dzd9PRiawMt-O4BgGNpiaDLI8"></p>
</li>
</ol>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/hexo/tags/%E7%BD%91%E7%BB%9C/" rel="tag"># 网络</a>
              <a href="/hexo/tags/VLAN/" rel="tag"># VLAN</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/%E4%BA%A4%E6%8D%A2%E6%9C%BA%E5%9F%BA%E7%A1%80/" rel="prev" title="交换基础">
      <i class="fa fa-chevron-left"></i> 交换基础
    </a></div>
      <div class="post-nav-item">
    <a href="/hexo/2020/07/05/na/%E4%BA%A4%E6%8D%A2/GVRP/" rel="next" title="ACL">
      ACL <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#VLAN"><span class="nav-number">1.</span> <span class="nav-text">VLAN</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5"><span class="nav-number">1.1.</span> <span class="nav-text">1. 基础概念</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-%E6%95%B0%E6%8D%AE%E5%8C%85%E5%BD%A2%E5%BC%8F"><span class="nav-number">1.2.</span> <span class="nav-text">2. 数据包形式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-%E9%93%BE%E8%B7%AF%E6%8E%A5%E5%85%A5%E7%B1%BB%E5%9E%8B"><span class="nav-number">1.3.</span> <span class="nav-text">3.链路接入类型</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-VLAN%E8%A7%84%E5%88%92"><span class="nav-number">1.4.</span> <span class="nav-text">3.VLAN规划</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-VLAN%E9%85%8D%E7%BD%AE%E5%91%BD%E4%BB%A4%E6%80%BB%E7%BB%93"><span class="nav-number">1.5.</span> <span class="nav-text">4.VLAN配置命令总结</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-%E5%9F%BA%E7%A1%80%E5%AE%9E%E9%AA%8C%E6%80%BB%E7%BB%93"><span class="nav-number">1.6.</span> <span class="nav-text">5.基础实验总结</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-VLAN%E7%BB%BC%E5%90%88%E5%AE%9E%E9%AA%8C"><span class="nav-number">1.7.</span> <span class="nav-text">6. VLAN综合实验</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Liang HF</p>
  <div class="site-description" itemprop="description">普通人</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/hexo/archives/">
        
          <span class="site-state-item-count">15</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/hexo/categories/">
          
        <span class="site-state-item-count">2</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/hexo/tags/">
          
        <span class="site-state-item-count">15</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Liang HF</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/hexo/lib/anime.min.js"></script>
  <script src="/hexo/lib/velocity/velocity.min.js"></script>
  <script src="/hexo/lib/velocity/velocity.ui.min.js"></script>

<script src="/hexo/js/utils.js"></script>

<script src="/hexo/js/motion.js"></script>


<script src="/hexo/js/schemes/pisces.js"></script>


<script src="/hexo/js/next-boot.js"></script>




  















  

  

</body>
</html>
